home *** CD-ROM | disk | FTP | other *** search
- from PSPApp import *
-
- # Copyright 2006 Corel Software Inc., all rights reserved
- # This file contains utility routines provided by Corel Software.
- # This file contains all translatable strings for the bundled script files.
-
- ScriptData = {}
-
- class SaveSelection:
- ''' define a helper class that can save any active selection to the alpha
- channel and restore it later
- '''
- def __init__( self, Environment, Doc ):
- ''' at init time we save the environment variable provided by PSP,
- and if a selection exists we save it to an alpha channel
- '''
- self.Env = Environment
- self.SavedSelection = '__$TempSavedSelection$__'
- self.IsSaved = 0
- self.SavedOnDoc = Doc
-
- SelResult = App.Do( self.Env, 'GetRasterSelectionRect' )
- if SelResult[ 'Type' ] != App.Constants.SelectionType.None:
- # if there is a selection save it to the alpha channel
- App.Do( self.Env, 'SelectSaveDisk', {
- 'FileName': self.SavedSelection,
- 'Overwrite': App.Constants.Boolean.true,
- 'GeneralSettings': {
- 'ExecutionMode': App.Constants.ExecutionMode.Silent,
- 'AutoActionMode': App.Constants.AutoActionMode.Match
- }
- }, Doc)
- self.IsSaved = 1 # set this so we know we saved one
-
- if SelResult[ 'Type' ] == App.Constants.SelectionType.Floating:
- # if the selection is floating promote it to a layer
- App.Do( self.Env, 'SelectPromote', {
- 'KeepSelection': App.Constants.Boolean.false,
- 'LayerName': SelectionLayer,
- 'GeneralSettings': {
- 'ExecutionMode': App.Constants.ExecutionMode.Silent,
- 'AutoActionMode': App.Constants.AutoActionMode.Match
- }
- }, Doc)
- else:
- App.Do( self.Env, 'SelectNone' )
-
-
- def RestoreSelection( self ):
- ''' if we have saved a selection, restore it now. If we promoted
- a floating selection to a layer we don't restore the selection
- but don't attempt to mess with the layer in any way
- '''
- if self.IsSaved == 1:
- # load the selection back from disk - this will replace any existing selection
- App.Do( self.Env, 'SelectLoadDisk', {
- 'FileName': self.SavedSelection,
- 'Operation': App.Constants.SelectionOperation.Replace,
- 'UpperLeft': App.Constants.Boolean.false,
- 'ClipToCanvas': App.Constants.Boolean.false,
- 'GreyMethod': App.Constants.CreateMaskFrom.Luminance,
- 'Invert': App.Constants.Boolean.false,
- 'GeneralSettings': {
- 'ExecutionMode': App.Constants.ExecutionMode.Silent,
- 'AutoActionMode': App.Constants.AutoActionMode.Match
- }
- }, self.SavedOnDoc)
-
- # end class SaveSelection
-
- def NameFromMaterial( Material, Delimiter=' ', IncludeTexture=1 ):
- ''' Given a material repository, return a name that describes it.
- By default the name is delimited with space, but the delimiter
- parameter can be used to override it.
- By default textures are included in the name, but can be omitted
- by setting the IncludeTexture parameter to 0
- '''
- TextureName = None
- TypeName = ''
- if Material is None:
- CoreName = Null
- else:
- if Material[ 'Pattern' ] and \
- (Material[ 'Pattern' ][ 'Name' ] or Material[ 'Pattern' ][ 'Image' ] ):
- TypeName = Pattern
- if Material[ 'Pattern' ][ 'Name' ]:
- CoreName = Material[ 'Pattern' ][ 'Name' ]
- else:
- CoreName = Inline
- elif Material[ 'Gradient' ] and Material[ 'Gradient' ][ 'Name' ]:
- TypeName = Gradient
- GradType = {}
- GradType[ App.Constants.GradientType.Linear ] = Linear
- GradType[ App.Constants.GradientType.Rectangular ] = Rectangular
- GradType[ App.Constants.GradientType.Radial ] = Radial
- GradType[ App.Constants.GradientType.Angular ] = Sunburst
-
- CoreName = '%s%s%s' % ( Material[ 'Gradient' ][ 'Name' ], Delimiter,
- GradType[ Material[ 'Gradient' ][ 'GradientType' ] ] )
- elif Material[ 'Art' ]:
- TypeName = Art
- CoreName = '%02x%02x%02x' % Material[ 'Art' ][ 'Color' ]
- else:
- TypeName = Solid
- CoreName = '%02x%02x%02x' % Material[ 'Color' ]
-
- if Material[ 'Texture' ] and Material[ 'Texture' ][ 'Name' ]:
- TextureName = Material[ 'Texture' ]['Name']
-
- if TextureName is not None and IncludeTexture != 0:
- MaterialName = '%s%s%s%s%s' % ( TypeName, Delimiter, CoreName, Delimiter, TextureName )
- else:
- MaterialName = '%s%s%s' % ( TypeName, Delimiter, CoreName )
-
- return MaterialName
-
- def IsNullMaterial( Material ):
- ' check if the passed in material is none. Returns true if null, false if non-null'
- if Material is None:
- return App.Constants.Boolean.true # material might be entirely none
-
- ArtIsNone = 0
- ColorIsNone = 0
- GradientIsNone = 0
- PatternIsNone = 0
-
- if Material['Color'] is None:
- ColorIsNone = 1
-
- if Material['Gradient'] is None or Material['Gradient']['Name'] is None:
- GradientIsNone = 1
-
- if Material['Pattern'] is None or \
- (Material['Pattern']['Name'] is None and Material['Pattern']['Image'] is None):
- PatternIsNone = 1
-
- if Material['Art'] is None:
- ArtIsNone = 1
-
- if ColorIsNone and GradientIsNone and PatternIsNone and ArtIsNone:
- return App.Constants.Boolean.true #it works out to none
- else:
- return App.Constants.Boolean.false
-
-
- def IsFlatImage( Environment, Doc ):
- 'Determine if Doc consists of a single background layer. True if flat, false if not'
- ImageInfo = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
- LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
-
- if ImageInfo[ 'LayerNum' ] == 1 and LayerInfo[ 'IsBackground' ] == App.Constants.Boolean.true:
- return App.Constants.Boolean.true
- else:
- return App.Constants.Boolean.false
-
- def IsPaletted( Environment, Doc ):
- '''Determine if the current image is paletted. Greyscale is not counted as paletted
- Returns true on paletted, false if not
- '''
- # these are all the paletted pixel formats
- TargetFormats = [ App.Constants.PixelFormat.Index1, App.Constants.PixelFormat.Index4,
- App.Constants.PixelFormat.Index8 ]
-
- # are we paletted?
- Info = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
-
- if Info['PixelFormat'] in TargetFormats:
- return App.Constants.Boolean.true
- else:
- return App.Constants.Boolean.false
-
- def IsTrueColor( Environment, Doc ):
- ''' Determine if the current image is true color. Greyscale does not count
- Returns true for true color, false for all others
- '''
- TargetFormats = [ App.Constants.PixelFormat.BGR, App.Constants.PixelFormat.BGRA ]
-
- # are we true color?
- Info = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
- if Info['PixelFormat'] in TargetFormats:
- return App.Constants.Boolean.true
- else:
- return App.Constants.Boolean.false
-
- def IsGreyScale( Environment, Doc ):
- ' Determine if the current image (not layer) is greyscale. True if it is, false otherwise'
- TargetFormats = [ App.Constants.PixelFormat.Grey, App.Constants.PixelFormat.GreyA ]
-
- # are we true color?
- Info = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
- if Info['PixelFormat'] in TargetFormats:
- return App.Constants.Boolean.true
- else:
- return App.Constants.Boolean.false
-
- def LayerIsArtMedia( Environment, Doc ):
- 'Returns true if the current layer is a artmedia layer'
- LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
- if LayerInfo[ 'LayerType' ] == App.Constants.LayerType.ArtMedia:
- return App.Constants.Boolean.true
- else:
- return App.Constants.Boolean.false
-
- def LayerIsRaster( Environment, Doc ):
- 'Returns true if the current layer is a raster layer'
- LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
- if LayerInfo[ 'LayerType' ] == App.Constants.LayerType.Raster:
- return App.Constants.Boolean.true
- else:
- return App.Constants.Boolean.false
-
-
- def LayerIsVector( Environment, Doc ):
- 'Returns true if the current layer is a vector layer'
- LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
- if LayerInfo[ 'LayerType' ] == App.Constants.LayerType.Vector:
- return App.Constants.Boolean.true
- else:
- return App.Constants.Boolean.false
-
- def LayerIsBackground( Environment, Doc ):
- 'Returns true if the current layer is the background layer'
- LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
- return LayerInfo[ 'IsBackground' ]
-
-
- def GetLayerCount( Environment, Doc ):
- 'Returns number of layers in Doc'
- ImageInfo = App.Do( Environment, 'ReturnImageInfo', {}, Doc )
- return ImageInfo[ 'LayerNum' ]
-
- def GetCurrentLayerName( Environment, Doc ):
- 'Returns the name of the current layer in Doc'
- LayerInfo = App.Do( Environment, 'ReturnLayerProperties', {}, Doc )
- return LayerInfo[ 'General' ][ 'Name' ]
-
- def PromoteToTrueColor( Environment, Doc ):
- 'If the current image type is paletted, promote it to true color. Greyscale is left alone'
- if IsPaletted( Environment, Doc ):
- App.Do( Environment, 'IncreaseColorsTo16Million', {}, Doc )
- return
-
- def RequireADoc( Environment ):
- '''Test that we actually have a target document, and put up a message box if we dont
- Returns true if we have an open doc, false otherwise
- '''
- if App.TargetDocument is None:
- App.Do( Environment, 'MsgBox', {
- 'Buttons': App.Constants.MsgButtons.OK,
- 'Icon': App.Constants.MsgIcons.Stop,
- 'Text': RequiresOpenImage,
- })
- return App.Constants.Boolean.false
- else:
- return App.Constants.Boolean.true
-
- # Begin Translatable Strings
- # BevelSelection.PspScript:
- LayerName_BevelSelection = u"Selezione smussata"
-
- # Black and white pencil.PspScript:
- LayerName_Blackandwhitepencil = u"Raster 2"
-
- # Border with drop shadow.PspScript:
- AlphaName = u"Selection #1"
-
- # Flag.PspScript:
- #AlphaName = u"Selection #1"
-
- # Grey chart.PspScript:
- GradientName = u"Primo piano-sfondo"
-
- # Sloppy edges.PspScript:
- #AlphaName = u"Selection #1"
-
- # Toned greyscale.PspScript:
- LayerName_Tonedgreyscale = u"Bilanciamento colore 1"
-
- # Vignette.PspScript:
- LayerName_Vignette = u"Raster 2"
-
- # Photo edges.PspScript:
- LayerName_Photoedges = u"Raster 2"
-
- # SimpleCaption.PspScript:
- ImageTooSmallMsg = u"Immagine corrente troppo piccola per assegnarle un titolo - Deve essere almeno 200x200."
- MultipleLayersMsg = u"L'immagine corrente Φ distribuita su pi∙ livelli. Si potrebbero ottenere risultati imprevedibili.\n╚ consigliabile appiattire l'immagine prima di proseguire. Appiattire l'immagine?"
- CaptionPrompt = u"Immettere un titolo per l'immagine. Verrα posto sotto l'immagine e centrato."
- CaptionTitle = u"Immettere il titolo dell'immagine"
- PromotedLayerName = u"Immagine"
- PageSurfaceLayerName = u"Superficie della pagina"
- AlbumPageLayerGroup = u"Pagina album"
- DropShadowLayerName = u"Sfumatura"
- CaptionTextLayerName = u"Testo del titolo"
- CaptionFontName2 = u"Tahoma"
-
- # VectorMergeAndCutoutSelected.PspScript:
- TwoOrMoreMsg = u"Per usare questo script devono essere selezionati due o pi∙ oggetti vettoriali."
-
- # VectorMergeSelected.PspScript:
- #TwoOrMoreMsg = u"This script requires that two or more vector objects be selected."
-
- # AddPSP8FileLocations.PspScript:
- NoPSP8FoldersFound = u"Non sono state trovate cartelle di PSP8."
- FilesHaveBeenAdded = u"I file in '%s' sono stati aggiunti alle preferenze per i percorsi dei file."
- Brushes = u"Pennelli"
- BumpMaps = u"Mappe di rugositα"
- DeformationMaps = u"Mappe di deformazione"
- DisplacementMaps = u"Mappe di posizionamento"
- EnvironmentMaps = u"Mappe ambiente"
- Gradients = u"Gradienti"
- Masks = u"Maschere"
- Palettes = u"Tavolozze"
- Patterns = u"Motivi"
- PictureFrames = u"Cornici immagine"
- PictureTubes = u"Ornamenti"
- PresetShapes = u"Forme predefinite"
- Presets = u"Impostazioni predefinite"
- PrintTemplates = u"Modelli di stampa"
- QuickGuides = u"Esercitazioni"
- SampleImages = u"Immagini campione"
- ScriptsRestricted = u"Script con restrizioni"
- ScriptsTrusted = u"Script sicuri"
- Selections = u"Selezioni"
- StyledLines = u"Linee stilizzate"
- Swatches = u"Campioni"
- Textures = u"Trame"
-
- # AddPSP8FileLocationsALL.PspScript:
- #NoPSP8FoldersFound = u"No PSP8 folders found."
- #FilesHaveBeenAdded = u"Files in '%s' have been added to the File Locations preferences."
- #Brushes = u"Brushes"
- #BumpMaps = u"Bump Maps"
- #DeformationMaps = u"Deformation Maps"
- #DisplacementMaps = u"Displacement Maps"
- #EnvironmentMaps = u"Environment Maps"
- #Gradients = u"Gradients"
- #Masks = u"Masks"
- #Palettes = u"Palettes"
- #Patterns = u"Patterns"
- #PictureFrames = u"Picture Frames"
- #PictureTubes = u"Picture Tubes"
- #PresetShapes = u"Preset Shapes"
- #Presets = u"Presets"
- #PrintTemplates = u"Print Templates"
- #QuickGuides = u"Quick Guides"
- #SampleImages = u"Sample Images"
- #ScriptsRestricted = u"Scripts-Restricted"
- #ScriptsTrusted = u"Scripts-Trusted"
- #Selections = u"Selections"
- #StyledLines = u"Styled Lines"
- #Swatches = u"Swatches"
- #Textures = u"Textures"
-
- # CapturePalette.PspScript:
- RequiresPaletted = u"Questo script richiede un'immagine con tavolozza. Ridurre la profonditα del colore?"
- NoPaletteFound = u"Errore interno: Non sono state trovate tavolozze"
- GroutWidthMsg = u"Il valore di GroutWidth deve essere compreso fra 0 e 20"
- ColorsPerRowMsg = u"Il valore di ColorsPerRow deve essere compreso fra 1 e 100"
- TileSizeMsg = u"Il valore di TileSize deve essere compreso fra 2 e 50"
- NumColorsMsg = u"Il numero di colori deve essere compreso fra 2 e 1024"
- ButtonMarginMsg = u"Il valore di ButtonMargin deve essere inferiore alla metα del valore di TileSize"
- ColorIs = u"Il colore %d Φ (%02X,%02X,%02X)"
-
- # EXIFCaptioning.PspScript:
- NoEXIFData = u"Non sono stati trovati dati EXIF nell'immagine corrente."
- ExposureMsg = u"f/%g apertura, %s esposizione"
- CaptionBackground = u"Sfondo del titolo"
- EXIFCaption = u"Titolo EXIF"
- EXIFText = u"Testo EXIF"
- CaptionFontName = u"Arial"
-
- # SplitCMYKtoLayerGroup.PspScript:
- Black = u"Nero"
- BlackChannel = u"Canale nero"
- Yellow = u"Giallo"
- YellowChannel = u"Canale giallo"
- Magenta = u"Magenta"
- MagentaChannel = u"Canale magenta"
- Cyan = u"Ciano"
- CyanChannel = u"Canale ciano"
- CMYKChannels = u"Canali CMYK"
-
- # SplitHSLtoLayerGroup.PspScript:
- Lightness = u"Luminanza"
- LightnessChannel = u"Canale luminanza"
- Saturation = u"Saturazione"
- SaturationChannel = u"Canale saturazione"
- Hue = u"Tonalitα"
- HueChannel = u"Canale tonalitα"
- HSLChannels = u"Canali HSL"
-
- # SplitRGBtoLayerGroup.PspScript:
- Blue = u"Blu"
- BlueChannel = u"Canale blu"
- Green = u"Verde"
- GreenChannel = u"Canale verde"
- Red = u"Rosso"
- RedChannel = u"Canale rosso"
- RGBChannels = u"Canali RGB"
-
- # JascUtils.py, PSPUtils.py
- SelectionLayer = u"Selezione sollecitata tramite script"
- Pattern = u"Motivo"
- Inline = u"Inline"
- Gradient = u"Gradiente"
- Linear = u"Lineare"
- Radial = u"Radiale"
- Rectangular = u"Rettangolare"
- Sunburst = u"Sprazzo di luce"
- Solid = u"Pieno"
- Null = u"Nullo"
- Art = u"Disegni artistici"
- RequiresOpenImage = u"Per usare questo script deve essere aperta un'immagine."
- # End Translatable Strings
-
-